package com.yonyou.pmclouds.projecttype.rmiimpl;

import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.ref.itf.RefCodeConst;
import com.yonyou.pmclouds.basecom.ref.itf.ReferenceCheckOfBusiness;
import com.yonyou.pmclouds.basecom.runtime.RuntimeEnvironment;
import com.yonyou.pmclouds.project.rmiitf.ProjectSimpleQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class ReferenceCheckProjectType implements ReferenceCheckOfBusiness {
    @Autowired
    private ProjectSimpleQuery query;
    @Override
    public String[] getReferenceCode() {
        return new String[]{RefCodeConst.PROJECTTYPE};
    }

    @Override
    public boolean checkReferenced(String bdCode, String[] keys) throws BusinessException {
        String code=null;
        if (RefCodeConst.PROJECTTYPE.equals(bdCode)){
            code= "pk_project_type";
        }else {
            throw new BusinessException("项目并未引用项目类型档案");
        }
        String tenantId = RuntimeEnvironment.getTenantId();
        return query.quote(tenantId,code,keys);
    }
}
